if (!jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.userMgt.user.SuperUserSearchBar")) {
    jsx3.require("jsx3.gui.Block")
    /**
     *
     */
    jsx3.lang.Package.definePackage("tibco.admin.enterpriseAssets.userMgt.user", function (superUserSearchbar) {
    });

    /**
     *
     */
    jsx3.lang.Class.defineClass("tibco.admin.enterpriseAssets.userMgt.user.SuperUserSearchBar",
            jsx3.gui.Block,
            null,
            function (susearchbar) {

                /**
                 * instance initializer
                 */
                susearchbar.prototype.initialize = function() {
                  //  if (jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.userMgt.window.Window")) {
                  //      this.windowObj = this.getAncestorOfType("tibco.admin.enterpriseAssets.userMgt.window.Window")
                  //      if (this.window) {
                  //          this.setWindowId(this.windowObj.getId());
                  //      }
                  //  }
                    var me = this;
                    this.searchBtn = this.getDescendantOfName("btnSearch_24_N_1");
                    this.searchBtn.doSearch = function(key) {
                        me.doSearch(key);
                    }

                }

               susearchbar.prototype.setWindow = function(window) {
                    this.windowObj = window
                    this.setWindowId(this.windowObj.getId());
                }

                /**
                 *   set the current window ID
                 *   @para strId {string} The window id
                 */
                susearchbar.prototype.setWindowId = function(strId) {
                    this.windowId = strId;
                }

                /**
                 *   get the current window ID
                 *   @return {string} The window id
                 */
                susearchbar.prototype.getWindowId = function() {
                    return this.windowId;
                }


                /**
                 * This function is to show and hide the serach bar
                 */
                susearchbar.prototype.show = function(objEvent) {
                    var searchLayer = this.getDescendantOfName("blkBtm_24_N_1");
                    if ((searchLayer.getVisibility() == jsx3.gui.Block.VISIBILITYHIDDEN)) {
                        searchLayer.setVisibility(jsx3.gui.Block.VISIBILITYVISIBLE, true);
                        this.getParent().setZIndex(2, true);
                    }
                    else {
                        searchLayer.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN, true);
                        this.getParent().setZIndex(0, true);
                    }
                }




                /**
                 *	To generate the search function and load the result dialog
                 */
                susearchbar.prototype.doSearch = function(key) {
                    if (key.length == 0)
                        key = "*";
                    var loadTo = this.windowObj;
                    var body = tibco.admin.Main.getServer().getBodyBlock();
                    var parent = this.windowObj.getParent();
                    while (parent) {
                        if (parent == body) {
                            loadTo = body;
                            break;
                        }
                        parent = parent.getParent();
                    }
                    var addUserPopup = tibco.admin.Main.loadUIResource(loadTo, "tibco.admin", "tibco/admin/enterpriseAssets/userMgt/window/user/ui/addSuperUsers.xml", true);
                    var searchKeyword = addUserPopup.getDescendantOfName("txtKeyword_24_N_2");
                    searchKeyword.setValue(key);
                    addUserPopup.callsearchUsers();
                    var searchLayer = this.getDescendantOfName("blkBtm_24_N_1");
                    if ((searchLayer.getVisibility() == jsx3.gui.Block.VISIBILITYVISIBLE))
                    {
                        searchLayer.setVisibility(jsx3.gui.Block.VISIBILITYHIDDEN, true);
						this.getParent().setZIndex(0, true); 
                    }
                }




                /**
                 *	  Search users - webservice call
                 */
                susearchbar.prototype.callsearchUsers = function() {
                    var objService = APP.tibco.admin.loadResource("searchUsers_xml");
                    objService.setOperation("searchUsers");

                    //subscribe and call
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, this, this.onsearchUsersSuccess);
                    //objService.subscribe(jsx3.net.Service.ON_ERROR, this,this.onsearchUsersError);
                    //objService.subscribe(jsx3.net.Service.ON_INVALID, this,this.onsearchUsersInvalid);
                    objService.doCall();
                };

                susearchbar.prototype.onsearchUsersSuccess = function(objEvent) {
                };

                susearchbar.prototype.onsearchUsersError = function(objEvent) {
                    var myStatus = objEvent.target.getRequest().getStatus();
                    tibco.admin.util.Log.USERMGT.error("Error", "The service call failed. The HTTP Status code is: " + myStatus);
                };

                susearchbar.prototype.onsearchUsersInvalid = function(objEvent) {
                    tibco.admin.util.Log.USERMGT.error("Invalid", "The following message node just failed validation:\n\n" + objEvent.message);
                };

            });
}